<template>
  <div>
    <h1>当前求和为：{{$store.state.sum}}</h1>
    <select v-model="n">
      <option :value="1">1</option>
      <option :value="2">2</option>
      <option :value="3">3</option>
    </select>
    <button @click="increament">+</button>
    <button @click="decreament">-</button>
    <button @click="increamentOdd">当前求和为奇数再加</button>
    <button @click="increamentWait">+</button>
  </div>
</template>

<script>
  export default {
    name: "Count",
    data() {
      return {
        n: 1,
      }
    },
    methods: {
      increament() {
        // 注意大小写 注意对应的是actions还是mutations
        // this.$store.dispatch("jia", this.n)
        this.$store.commit("JIA", this.n)
      },
      decreament() {
        // this.$store.dispatch("jian", this.n)
        this.$store.commit("JIAN", this.n)
      },
      increamentOdd() {
        this.$store.dispatch("jiaOdd", this.n)
      },
      increamentWait() {
        this.$store.dispatch("jiaWait", this.n)
      },
    },
    mounted() {
      // console.log("Count", this)
    }
  }
</script>

<style>

</style>